<?php
/**
 *通用获取POST 和 GET数据 没有值返回null
 */
function getRequest($val,$ret=null){
	return isset($_REQUEST[$val])?$_REQUEST[$val]:$ret;
}

/*
 * 获取用户IP的函数
 */
function getIp(){
	$onlineip = "";
	if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
	    $onlineip = getenv('HTTP_CLIENT_IP');
	} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
	    $onlineip = getenv('HTTP_X_FORWARDED_FOR');
	} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
	    $onlineip = getenv('REMOTE_ADDR');
	} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
	    $onlineip = $_SERVER['REMOTE_ADDR'];
	}
	return $onlineip;
}

function getThisOrder($arr,$index){
	$ret = array();
	for($i=$index;$i<count($arr);$i++){
		array_push($ret,$arr[$i]);
	}
	for($i=0;$i<$index;$i++){
		array_push($ret,$arr[$i]);
	}

	return json_encode($ret);
}

/**
 * Sends the given data to the Fire_Fb Firefox Extension.
 * The data can be displayed in the Firebug Console or in the
 * "Server" request tab.
 * 
 * @see http://www.Fire_Fb.org/Wiki/Reference/Fb
 * @param mixed $Object
 * @return true
 * @throws Exception
 */
function fb()
{
    $instance = Fire_Fb::getInstance(true);
  
    $args = func_get_args();
    return call_user_func_array(array($instance,'fb'),$args);
}
/**
 *得到当前域名
 */
function getdomain(){
	return $domain = strtolower(trim($_SERVER['SERVER_NAME']));
}
?>